﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.General;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service
{
    public class AboutPageContentService: IService<AboutPageContents>
    {
        private readonly GenericRepository<AboutPageContents> _aboutPageContentRepository;
        private readonly IUnitOfWork _unitOfWork;

        public AboutPageContentService(IUnitOfWork unitOfWork, GenericRepository<AboutPageContents> aboutPageContentRepository)
        {
            this._aboutPageContentRepository = aboutPageContentRepository;
            this._unitOfWork = unitOfWork;
        }

        public IQueryable<AboutPageContents> GetAllElements()
        {
            return _aboutPageContentRepository.GetAll();
        }

        public AboutPageContents GetElementById(int id)
        {
            return _aboutPageContentRepository.GetById(id);
        }

        public void CreateElement(AboutPageContents entity)
        {
            _aboutPageContentRepository.Insert(entity);
        }

        public void UpdateElement(AboutPageContents entity)
        {
            _aboutPageContentRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _aboutPageContentRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
